package experiment3.task1;

import java.util.Scanner;

/**
 * @author 冯永龙
 * @date 2021/3/30 21:10
 */
public class Test {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PersonManager<Person> personManager = new PersonManager<>();
        Class<?> aClass = personManager.createObject();
        do {
            System.out.println("请输入你的操作：1--添加  2--根据id查找对象  3--查找所有对象  4--删除对象");
            int operation = sc.nextInt();
            int id;
            switch (operation) {
                case 1:
                    personManager.add();
                    break;
                case 2:
                    System.out.print("请输入id:");
                    id = sc.nextInt();
                    personManager.findById(id);
                    break;
                case 3:
                    personManager.findAll();
                    break;
                case 4:
                    System.out.println("所有对象:");
                    personManager.findAll();
                    System.out.println("输入删除对象的id");
                    id = sc.nextInt();
                    System.out.print("删除的对象为: ");
                    Person manager = personManager.findById(id);
                    if (manager != null)
                        personManager.remove(manager);
                    break;
            }

            System.out.print("输入1继续：");
            int input = sc.nextInt();
            if (input != 1)
                break;

        } while (true);
    }
}


